home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / program / skeleton.zip / Misc.asm < prev    next >
Assembly Source File  |  1996-06-02  |  1KB  |  58 lines

  1.         TITLE    Misc
  2.         INCLUDE    COMMON.INC
  3.  
  4.  
  5.         .CODE
  6. MiscCenterWnd    PROC    STDCALL, hChild:HWND, hParent:HWND
  7.         LOCAL    rcP:RECT, rcC:RECT
  8.         LOCAL    xNew:DWORD, yNew:DWORD
  9.  
  10.         INVOKE    GetWindowRect, hParent, ADDR rcP
  11.         test    eax,eax
  12.         jz    caseRETURN
  13.  
  14.         INVOKE    GetWindowRect, hChild, ADDR rcC
  15.         test    eax,eax
  16.         jz    caseRETURN
  17.  
  18.         mov    eax,rcP.right    ;center horizontally
  19.         sub    eax,rcP.left    ;x=Px+(Pdx-Cdx)/2
  20.         sub    eax,rcC.right
  21.         add    eax,rcC.left
  22.         sar    eax,1h
  23.         add    eax,rcP.left
  24.         jns    @F        ;check if off screen at left
  25.         xor    eax,eax
  26. @@:        mov    xNew,eax
  27.  
  28.         INVOKE    GetSystemMetrics, SM_CXFULLSCREEN
  29.         sub    eax,rcC.right
  30.         add    eax,rcC.left
  31.         cmp    eax,xNew    ;check if off screen at right
  32.         ja    @F
  33.         mov    xNew,eax
  34.  
  35. @@:        mov    eax,rcP.bottom    ;center vertically
  36.         sub    eax,rcP.top    ;y=Py+(Pdy-Cdy)/2
  37.         sub    eax,rcC.bottom
  38.         add    eax,rcC.top
  39.         sar    eax,1h
  40.         add    eax,rcP.top
  41.         jns    @F        ;check if off screen at top
  42.         xor    eax,eax
  43. @@:        mov    yNew,eax
  44.  
  45.         INVOKE    GetSystemMetrics, SM_CYFULLSCREEN
  46.         sub    eax,rcC.bottom
  47.         add    eax,rcC.top
  48.         cmp    eax,yNew    ;check if off screen at bottom
  49.         ja    @F
  50.         mov    yNew,eax
  51.  
  52. @@:        INVOKE    SetWindowPos, hChild, NULL,\
  53.             xNew, yNew, 0h, 0h, SWP_NOSIZE + SWP_NOZORDER
  54. caseRETURN:    ret
  55. MiscCenterWnd    ENDP
  56.  
  57.         END
  58.